package com.ruoyi.web.controller.newTable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TClassNum;
import com.ruoyi.system.service.ITClassNumService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 给本科生上课的正教授人数Controller
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@RestController
@RequestMapping("/system/num")
public class TClassNumController extends BaseController
{
    @Autowired
    private ITClassNumService tClassNumService;

    /**
     * 查询给本科生上课的正教授人数列表
     */
    @PreAuthorize("@ss.hasPermi('system:num:list')")
    @GetMapping("/list")
    public TableDataInfo list(TClassNum tClassNum)
    {
        startPage();
        List<TClassNum> list = tClassNumService.selectTClassNumList(tClassNum);
        return getDataTable(list);
    }

    /**
     * 导出给本科生上课的正教授人数列表
     */
    @PreAuthorize("@ss.hasPermi('system:num:export')")
    @Log(title = "给本科生上课的正教授人数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TClassNum tClassNum)
    {
        List<TClassNum> list = tClassNumService.selectTClassNumList(tClassNum);
        ExcelUtil<TClassNum> util = new ExcelUtil<TClassNum>(TClassNum.class);
        util.exportExcel(response, list, "给本科生上课的正教授人数数据");
    }

    /**
     * 获取给本科生上课的正教授人数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:num:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tClassNumService.selectTClassNumById(id));
    }

    /**
     * 新增给本科生上课的正教授人数
     */
    @PreAuthorize("@ss.hasPermi('system:num:add')")
    @Log(title = "给本科生上课的正教授人数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TClassNum tClassNum)
    {
        return toAjax(tClassNumService.insertTClassNum(tClassNum));
    }

    /**
     * 修改给本科生上课的正教授人数
     */
    @PreAuthorize("@ss.hasPermi('system:num:edit')")
    @Log(title = "给本科生上课的正教授人数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TClassNum tClassNum)
    {
        return toAjax(tClassNumService.updateTClassNum(tClassNum));
    }

    /**
     * 删除给本科生上课的正教授人数
     */
    @PreAuthorize("@ss.hasPermi('system:num:remove')")
    @Log(title = "给本科生上课的正教授人数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tClassNumService.deleteTClassNumByIds(ids));
    }
}
